﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Agile.Engine.Data;

namespace Agile.Engine.Plus
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                textBox1.Text = openFileDialog1.FileName;

            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            var ds = ExcelReader.Read(textBox1.Text);

            TableCreator tc = new TableCreator();
            tc.DataContext = DataContext.Create(comboBox1.Text, textBox2.Text);
            tc.DbProvider = comboBox1.Text;

            var asyn = new Action(() => tc.CreateTable(ds));
            var ar = asyn.BeginInvoke(null, null);
            asyn.EndInvoke(ar);

            MessageBox.Show("Success");
        }

        private void button3_Click(object sender, EventArgs e)
        {
            var ds = ExcelReader.Read(textBox1.Text);
            SchemaCreator sc = new SchemaCreator();
            sc.Dictionary = "C:\\会计制度";
            sc.CreateSchema(ds);
            MessageBox.Show("Success");

        }

        private void button4_Click(object sender, EventArgs e)
        {
            using (var f = new Form2())
            {
                f.ShowDialog();
            }
        }
    }
}
